{include file="common/header"/}

<div class="lemo-container">
    <div class="lemo-main">
        <div class="admin-main layui-anim layui-anim-upbit">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>列表</legend>
                <blockquote class="layui-elem-quote">
                    <div class="lemo-table">
                        <div class="layui-inline">
                            <input type="text" name="name" id='name' lay-verify="required" placeholder="{:lang('pleaseEnter')}" autocomplete="off" class="layui-input">
                        </div>
                        <a  href="javascript:;" class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="add" id="search1">
                            {:lang('search')}
                        </a>
                        <a  href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger reset" lay-filter="reset" id="reset">
                            重置
                        </a>
                        <a data-href='{:url("add")}' href="javascript:;" class="layui-btn layui-btn-sm layui-btn-warm add">{:lang('add')}</a>
                    </div>
                </blockquote>
            </fieldset>
            <table class="layui-table" id="list" lay-filter="list"></table>
			<!--导出表 不展示-->
			<div style="display: none;">
				<table id="data_export">
				</table>
			</div>
        </div>
    </div>
</div>


<script type="text/html" id="action">
    <a data-href="{:url('edit')}?id={{d.id}}" class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">{:lang('edit')}</a>
    <!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('delete')}</a> -->
</script>
<script type="text/html" id="status">
    <input type="checkbox" name="status"  value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" data-href="{:url('state')}" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="addtime">
    {{layui.util.toDateString(d.addtime*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="icon">
    <img class="img_sp" height="50px" src="{{d.icon}}" onclick="previewImgs(this)" />
</script>
{include file="common/footer"/}
<script>
    layui.config({
        base: "/static/admin/js/",
        version: true
    }).extend({
        Admin: 'Admin'
    }).use(['element','form', 'layer', 'Admin','table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
        tableIn = table.render({
            elem: '#list',
            url: '{:url("index")}',
            method: 'post',
            cols: [[
                // {checkbox: true, fixed: true},
                // {field: 'id', title: 'ID', fixed: true, sort: true},
                {field: 'name', title: '事件名称'},
				{field: 'status', title: '状态', width: 180, templet:'#status'},
                {field: 'addtime', title: '添加时间', templet:'#addtime'},
                {title:'操作',width:200, toolbar: '#action',align:"center"},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true
        });
        //搜索
        $(document).on('click','#search1',function(){
            var $name = $('#name').val();
            // if(!$keys){
            //     return layer.msg('请输入关键词');
            // }
            tableIn.reload({ page: {page: 1},where: {name: $name}});
        });
    });
</script>